<template>
	<view class="goods-item">
		<!-- 商品类型：秒杀、拼团 -->
		<view class="first-line">
			<!-- 秒杀 -->
			<view class="type-box" v-if="goods.goods_type === '秒杀'">
				<uni-icons type="contact" size="18"></uni-icons>
				<view class="text-box">秒杀</view>
				<view>10:23:09</view>
			</view>
			<!-- ；拼团 -->
			<view class="type-box" v-else>
				<uni-icons type="contact" size="18"></uni-icons>
				<view class="text-box">拼团</view>
			</view>
		</view>
		<!-- 商品详情 -->
		<view class="second-line">
			<!-- 选择按钮+图片框 -->
			<view class="left-box">
				<radio :checked="goods.goods_state" color="#FF0000" @click="radioClickHandler"/>
				<image src="../../static/my-images/test.jpg" class="goods-pic"></image>
			</view>
			<!-- 文字描述+价格+操作 -->
			<view class="right-box">
				<view class="goods-name">{{goods.goods_name}}</view>
				<!-- 是否限购 -->
				<view v-show="goods.goods_purchase_limit" class="purchase-limit">限购{{goods.goods_purchase_limit}}</view>
				<!-- 价格+操作 -->
				<view class="price-opera">
					<!-- 价格 -->
					<view class="goods-price"><text>￥</text>{{goods.goods_price}}</view>
					<view class="original-price">￥{{goods.goods_origin_price}}</view>
					<uni-number-box :min="1" :value="goods.goods_count" @change="numChangeHandler"></uni-number-box>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"my-goods",
		data() {
			return {
				
			};
		},
		methods:{
			/* 修改商品数量 */
			numChangeHandler(){
				console.log('数量改变');
			},
			/* 勾选or取消勾选 */
			radioClickHandler(){
				this.$emit('radio-change',{
					goods_id:this.goods.goods_id,
					goods_state:!this.goods.goods_state
				})
			},
			/* 修改商品数量 */
			numChangeHandler(value){
				this.$emit('num-change',{
					goods_id:this.goods.goods_id,
					goods_count:value
				})
			}
		},
		onLoad() {
		},
		props:{
			goods:{
				type:Object,
				default:{}
			}
		}
	}
</script>

<style lang="scss">
	.goods-item {
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		background-color: white;
		.first-line {
			font-size: 12px;
			display: flex;
			.type-box {
				padding: 4rpx 10rpx;
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: flex-start;
				background-color: #f7f7f7;
				.text-box {
					margin-right: 20rpx;
					color: #ff0000;
				}
			}
		}
		.second-line {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-top: 20rpx;
			.left-box {
				display: flex;
				align-items: center;
				.goods-pic {
					width: 200rpx;
					height: 200rpx;
					display: block;
					margin-left: 10rpx;
				}
			}
			.right-box {
				margin-left: 10rpx;
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-items: flex-start;
				.goods-name {
					font-size: 14px;
					padding-right: 20rpx;
					color: #666;
				}
				.purchase-limit {
					display: inline-block;
					font-size: 12px;
					color: #ff0000;
					padding: 4rpx;
					margin-top: 10rpx;
					border: 2rpx solid #ff0000;
					border-radius: 10rpx;
					background-color: #FDE9E9;
				}
				.price-opera {
					margin-top: 40rpx;
					display: flex;
					align-items: center;
					.goods-price {
						color: #ff0000;
						font-size: 14px;
						text {
							font-size: 12px;
						}
					}
					.original-price {
						margin: 0 50rpx 0 10rpx;
						color: #efefef;
						text-decoration: line-through;
						font-size: 12px;
					}
				}
			}
		}
	}
</style>